package com.zzyy.study.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @auther zzyy
 * @create 2024-08-24 17:49
 */
@Configuration
public class RabbitMQConfiguration
{

    /**
     * 订单的rabbitmq配置，方式一
     */
    @Configuration
    public static class Order {
        public static final String EXCHANGE = "orderExchange";
        public static final String QUEUE = "orderQueue";
        public static final String ROUTING_KEY = "create";

        @Bean
        public DirectExchange orderExchange() {
            return new DirectExchange(EXCHANGE, true, false);
        }

        @Bean
        public Queue orderQueue() {
            return new Queue(QUEUE, true);
        }

        @Bean
        public Binding orderExchangeBindOrderQueue() {
            return new Binding(QUEUE, Binding.DestinationType.QUEUE, EXCHANGE, ROUTING_KEY, null);
        }
    }


    /**
     * 订单的rabbitmq配置，方式二
     */
    /*
    public static final String EXCHANGE = "orderExchange";
    public static final String QUEUE = "orderQueue";
    public static final String ROUTING_KEY = "create";

    @Bean
    public DirectExchange orderExchange()
    {
        return new DirectExchange(EXCHANGE, true, false);
    }

    @Bean
    public Queue orderQueue()
    {
        return new Queue(QUEUE, true);
    }

    @Bean
    public Binding orderExchangeBindOrderQueue()
    {
        return new Binding(QUEUE, Binding.DestinationType.QUEUE, EXCHANGE, ROUTING_KEY, null);
    }*/
}

